package org.ats.mail;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class mailTester {
	
	private static ApplicationContext context;

	public static void main(String args[]) throws InterruptedException{
		AtsMailSender ams;
		//Runnable ams;
		/*
		context = new ClassPathXmlApplicationContext("classpath:META-INF/spring.xml");
		ams = (AtsMailSender) context.getBean("AtsMailSender");
		//ams.sendSimpleMail();
		ams.PrepareMIMEMsg(MailTemplates.defaultTemp);
		//ams.sendMsg();
		Thread thread = new Thread(ams);
		thread.start();
		System.out.println(thread.getName() + "thread name exec time is: "  + new Date(System.currentTimeMillis()).toString());
		*/
		//##############################################################################################################
		//context = new ClassPathXmlApplicationContext("classpath:META-INF/spring.xml");
		//MailQueuer mq = (MailQueuer) context.getBean("MailQueuer");
		//mq.mailRunner();
		context = new ClassPathXmlApplicationContext("classpath:META-INF/spring.xml");
		/*
		MailThreadPool mtp = (MailThreadPool) context.getBean("MailThreadPool");
		for(int i=0;i<10;i++){
			mtp.mailSender();
		}
		System.out.println("after for " + new Date(System.currentTimeMillis()).toString());
		
		//System.out.println(MailTemplates.defaultTemp);
		 * 
		 */
		
		MailQueuer mq = (MailQueuer) context.getBean("MailQueuer");
		
		List<String> mailToList = new ArrayList<String>();
		mailToList.add("orwa@ats-ware.com");
		
		for(int i=0;i<10;i++){
			Thread.sleep(3000);
			mq.sendJMSMailMsg(MailTemplates.DEFAULT_TEMP, mailToList, new File("D:\\myfile.txt"));
		}

		System.out.println("after for mail send using jms " + new Date(System.currentTimeMillis()).toString());
		//MailTemplateProcessor tp = new MailTemplateProcessor();
		//System.out.println(tp.propertyLoader(MailTemplates.DEFAULT_TEMP).toString());
	}


}
